# 使用官方Rust镜像作为基础
FROM rust:1.87 AS builder

WORKDIR /app

# 复制清单文件并构建依赖
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo 'fn main() {}' > src/main.rs \
    && cargo build --release \
    && rm -rf src

# 复制源代码并构建应用
COPY src/ ./src/
RUN cargo build --release

FROM debian:bullseye-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/comp-agent /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/comp-agent"]